package com.douyin.service;

import com.douyin.entity.Video;
import com.douyin.mapper.VideoMapper;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;
// service是依赖mapper,只要把mapper以属性的形式注入进来
@Data // get,set,toString
@Service
public class VideoServiceImpl implements VideoService{
    @Autowired
    private VideoMapper videoMapper;  // 将mapper对象注入进来,这样就可以使用了

    @Override
    public List<Video> selectAllVideos() {
        return videoMapper.selectAllVideos();
    }

    @Override
    public Video selectVideoById(int id) {
        return videoMapper.selectVideoById(id);
    }

    @Override
    public Boolean deleteVideoById(int id) {
        return videoMapper.deleteVideoById(id)>0;
    }

    @Override
    public Boolean insertOneVideo(Video video) {
        return videoMapper.insertOneVideo(video)>0;
    }

    @Override
    public Boolean updateOneVideo(Video video) {
        return videoMapper.updateOneVideo(video)>0;
    }
}
